#include<unistd.h>
#include<stdio.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
int main()
{
    //close(1);
    //int fd=open("log.txt",O_WRONLY|O_CREAT|O_TRUNC,0666);
    int fd=open("log.txt",O_RDONLY);
    if(fd<0) return 1;
    //char buff[1024];
    dup2(fd,0);
    char buff[1024];
    fscanf(stdin,"%s",buff);
    printf("%s\n",buff);
    //fread(buff,1,sizeof(buff),stdin);
    //printf("%s\n",buff);
    //fprintf(stdout,"fd:%d\n",fd);
    //fprintf(stdout,"stdout->fd:%d\n",stdout->_fileno);
    //fflush(stdout);
    //fprintf(stdout,"hello fprint\n");
    close(fd);

    //close(1);
    //printf("hello linux\n");
    //fflush(stdout);
   // int fd=open("log.txt",O_WRONLY|O_CREAT|O_TRUNC,0666);
   // if(fd<0) return 1;
   // char buff[1024];
   // read(0,buff,sizeof(buff));
   // write(fd,buff,strlen(buff));
    //printf("%s\n",buff);
    return 0;
}
